<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: fzh
  Date: 2017/9/16
  Time: 14:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>管理员登录</title>
    <meta charset="UTF-8">
    <style type="text/css" media="screen">
        html, body {
            width: 100%;
            height: 100%;
            padding: 0;
            margin: 0;
        }

        @media screen and (max-width: 1080px) {
            body {
                width: 1080px;
            }
        }

        .main-pane {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            height: 100%;
            /* background-color: #F1F6F5; */
        }

        .content-pane {
            display: flex;
            width: 60%;
            height: 60%;
            min-height: 350px;
            border-radius: 10px;
            box-shadow: 5px 5px 10px #878787;
            background-color: #464545;
            align-items: center;
            justify-content: center;
            color: white;
        }

        .content-pane * {
            box-sizing: border-box;
        }

        .content-pane > .title {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            width: 30%;
            height: 100%;
            font-size: 2em;
            border-right: 2px solid white;
        }

        .content-pane form {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 40px 0;
            width: 70%;
            height: 100%;
            border-left: 2px solid white;
        }

        .item {
            display: flex;
            width: 100%;
            height: 20%;
        }

        .item * {
            display: flex;
            align-items: center;
        }

        .item > .label {
            justify-content: flex-end;
            box-sizing: border-box;
            padding-right: 20px;
            width: 40%;
            height: 60px;
            font-size: 1.1em;
        }

        .item > .input {
            width: 60%;
            height: 60px;
        }

        .input > input {
            box-sizing: border-box;
            padding: 2px 5px;
            font-size: 16px;
            caret-color: #464545;
        }

        .input * {
            outline: none;
            height: 60%;
            width: 70%;
        }

        .input > div {
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #01C632;
            border-radius: 3px;
        }

        .input > div:hover::before,
        .input > div:focus::before {
            content: "";
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(255, 255, 255, 0.1);
            cursor: pointer;
        }

        .input > div:active,
        .input > div:focus {
            top: 1px;
        }

        .error {
            color: #FF5050;
            font-size: 12px;
        }
    </style>
</head>
<body>
<div class="main-pane">
    <div class="content-pane">
        <div class="title">
            <span>后</span>
            <span>台</span>
            <span>管</span>
            <span>理</span>
        </div>
        <form action="<c:url value="/admin/check"/>" method="post" accept-charset="utf-8" name="loginForm">
            <div class="item">
                <div class="label">
                    <span>用戶名</span>
                </div>
                <div class="input">
                    <input id="un" type="text" name="username" value="" placeholder="請輸入用戶名">
                </div>
            </div>
            <div class="item">
                <div class="label">
                    <span>密码</span>
                </div>
                <div class="input">
                    <input id="pw" type="password" name="password" value="" placeholder="請輸入密码">
                </div>
            </div>
            <div class="item">
                <div class="label">
                </div>
                <div class="input">
                    <div onclick="check()">登录</div>
                </div>
            </div>
            <div class="item">
                <div class="label">
                </div>
                <div class="input error">
                    <span id="error">${requestScope.message}</span>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    function check() {
        let u = document.getElementById("un").value;
        let p = document.getElementById("pw").value;
        if (p.length < 6 || u.length > 20) {
            document.getElementById("error").innerHTML = "请核对您的用户名长度";
            return;
        }
        if (p.length < 6 || p.length > 32) {
            document.getElementById("error").innerHTML = "请核对您的密码长度";
            return;
        }
        document.loginForm.submit();
    }
</script>
</body>
</html>
